
package com.jf.cloud.user.listener;

import com.jf.cloud.api.user.bo.RechargeNotifyBO;
import com.jf.cloud.common.rocketmq.config.RocketMqConstant;
import com.jf.cloud.common.util.Json;
import com.jf.cloud.user.service.UserRechargeService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 余额充值回调
 * @author zz
 * @date 2021/1/7
 */
@Component
@RocketMQMessageListener(topic = RocketMqConstant.USER_RECHARGE_NOTIFY_TOPIC,consumerGroup = RocketMqConstant.USER_RECHARGE_NOTIFY_TOPIC)
public class RechargeNotifyConsumer implements RocketMQListener<RechargeNotifyBO> {

    @Autowired
    private UserRechargeService userRechargeService;

    private static final Logger LOG = LoggerFactory.getLogger(RechargeNotifyConsumer.class);

    @Override
    public void onMessage(RechargeNotifyBO message) {
        LOG.info("充值回调开始... message: " + Json.toJsonString(message));
        userRechargeService.rechargeSuccess(message);
    }
}
